﻿using System.Windows.Forms;

namespace RegexSharp.Control
{
    public class RSTreeView : TreeView
    {
        public RSTreeView()
        { }

        // Public Methods

        private delegate void AddNodeCallBack(TreeNode node);
        public void AddNode(TreeNode node)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new AddNodeCallBack(AddNode), new object[] { node });
            }
            else
            {
                this.Nodes.Add(node);
            }
        }

        private delegate void AddNodesCallBack(TreeNode[] nodes);
        public void AddNodes(TreeNode[] nodes)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new AddNodesCallBack(AddNodes), new object[] { nodes });
            }
            else
            {
                this.Nodes.AddRange(nodes);
            }
        }

        private delegate void ClearNodesCallBack();
        public void ClearNodes()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new ClearNodesCallBack(ClearNodes));
            }
            else
            {
                this.Nodes.Clear();
            }
        }
    }
}
